<template>
  <div>
      <div class="catrtory_head">
            <van-search @change="search" v-model="searchname" @click="searchclick" show-action label="JD" placeholder="请输入搜索关键词">
                <template #action>
                    <van-icon name="search" size="30" color="black" @click="search"/>
                </template>
            </van-search>
      </div>
  </div>
</template>

<script>
import {Search} from '../../../api/common'
export default {
    name:'catetoryhead',
    data() {
        return {
            searchname:'',
            searchList:[]
        }
    },
    methods: {
        searchclick(){
            this.$store.dispatch('changeSearch',false)
        },
        search(){
            this.$store.dispatch('searchName',this.searchname)
            Search({keywords:this.searchname,order:"1"}).then(res=>{
                // console.log("搜索数据",res)
                this.$store.dispatch("addSearchList",res.result.data)
                // this.$store.dispatch('changeSearch',true)
                this.searchname =""
            })
        }
    },
}
</script>

<style lang='less'>
.catrtory_head{
    box-sizing: border-box;
    width: 100%;
    height: 100px;
    line-height: 100px;
    position: fixed;
    top: 0;
    left: 0;
    .van-search{
        padding: 0 12px;
        .van-search__action{
            box-sizing: border-box;
            margin-top: 20px;
        }
    }
}
</style>